﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace DeploymentMaxLib
{
    public abstract class ActionBase
    {
        public ActionBase()
        {
            LogList = new List<ActionLog>();
            Result = new ActionResult();
        }

        public abstract string LongName { get; }
        public abstract string Description { get; }
        public abstract ActionResponse Execute(ActionRequest pRequest);
        public abstract ActionResult Validate(ActionRequest pRequest);

        public ActionResult Result { get; set; }

        public List<ActionLog> LogList { get; set; }

        public void AddLog(ActionLog pLog)
        {
            LogList.Add(pLog);
        }

        public void AddLog(string pLog)
        {
            LogList.Add(new ActionLog(pLog));
        }

        public void AddLog(string pLog, params object[] args)
        {
            LogList.Add(new ActionLog(string.Format(pLog, args)));
        }

        public void AddLog(ActionLogLevelType pLevel, string pLog)
        {
            LogList.Add(new ActionLog(pLog, pLevel));
        }

        public void AddLog(ActionLogLevelType pLevel, string pLog, params object[] args)
        {
            LogList.Add(new ActionLog(string.Format(pLog, args), pLevel));
        }
    }
}
